<!--
 * @Author: xiaotiwen
 * @Date: 2020-06-22 10:33:05
 * @LastEditTime: 2020-07-11 01:08:35
 * @LastEditors: xiaotiwen
 * @FilePath: \eduweb\src\views\practiceManagement\courseList\index.vue
 * @Description: 课程初始化
-->

<template>
    <!-- 课程初始化列表 -->
    <div>
        <InnerBreadcrumb v-model="indexKey" :path="breadPath"></InnerBreadcrumb>
        <div v-if="indexKey === '0'">
            <ConditionCard
                shadow="never"
                label-width="110px"
                @search="onSubmit"
                @reset="reset('queryForm')"
            >
                <el-row :gutter="24">
                    <el-col :span="8">
                        <el-form-item :label="$t('label.schoolTerm')">
                            <CalendarSelect
                                v-model="queryForm.yearTerm"
                                @load-done="getloadDone"
                            ></CalendarSelect>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.grade')">
                            <el-date-picker
                                v-model="queryForm.grade"
                                value-format="yyyy"
                                type="year"
                                :placeholder="$t('message.plzSelect')"
                                style="width: 100%"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.trainingLevel')">
                            <el-select
                                v-model="queryForm.trainingLevel"
                                :placeholder="$t('message.plzSelect')"
                                style="width:100%"
                                :disabled="true"
                            >
                                <el-option
                                    :label="$t('courseConfirmation.udg')"
                                    value="UDG"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="8">
                        <el-form-item :label="$t('fundingManagement.label.courseOpenAcademy')">
                            <DictSelect
                                v-model="queryForm.courseOpenAcademyId"
                                :data="options.courseOpenAcademyId"
                                :clearable="false"
                                :filterable="true"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('courseConfirmation.label.stuFaculty')">
                            <DictSelect
                                v-model="queryForm.studentAcademyId"
                                :data="options.studentAcademyId"
                                :clearable="false"
                                :filterable="true"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.major')">
                            <MyMajor
                                :faculty="queryForm.studentAcademyId"
                                :filterable="true"
                                v-model="queryForm.majorId"
                                :grade="queryForm.grade"
                            ></MyMajor>
                        </el-form-item>
                    </el-col>
                </el-row>
            </ConditionCard>
            <el-card shadow="never" body-style="padding: 24px;">
                <h2 class="titles">{{ $t('arrCourse.title.listTitle') }}</h2>
                <div class="edu-opertion-bar">
                    <div class="float-left">
                        <KeywordInput v-model="queryForm.course" :placeholder="$t('courseConfirmation.tips.keyTips')" @enter="handSearchChang"></KeywordInput>
                        <!-- <el-input
                            style="width: 200px;"
                            v-model="queryForm.course"
                            :placeholder="$t('courseConfirmation.tips.keyTips')"
                            prefix-icon="el-icon-search"
                            @keyup.enter.native="handSearchChang"
                        /> -->
                    </div>

                    <div class="float-right">
                        <el-button v-if="menuAuths.exportBut" type="primary" @click="exportRecord">
                            {{ $t('message.export') }}
                        </el-button>
                        <el-button v-if="menuAuths.deleteBatch" type="danger" @click="deleteItems">
                            {{ $t('arrCourse.btn.batchDelete') }}
                        </el-button>
                        <el-button v-if="menuAuths.initBut" type="primary" @click="initialize">
                            {{ $t('arrCourse.btn.initCourse') }}
                        </el-button>
                        <el-button v-if="menuAuths.addBut" type="primary" @click="addCourse">
                            {{ $t('message.add') }}
                        </el-button>
                    </div>
                </div>
                <el-table
                    ref="mainTables"
                    :data="data"
                    @selection-change="selectionChange"
                    @row-click="rowClick"
                    @expand-change="zydescription"
                    :row-class-name="setClassName"
                    :row-key="getRowKeys"
                    :expand-row-keys="expands"
                >
                    <el-table-column width="30" type="selection"></el-table-column>
                    <el-table-column
                        width="50"
                        align="center"
                        type="index"
                        :index="indexMainMethod"
                        :label="$t('message.order')"
                        fixed="left"
                    ></el-table-column>
                    <el-table-column
                        :min-width="item.width"
                        :align="item.center ? 'center' : ''"
                        v-for="(item, idx) in label"
                        :label="item.label"
                        :key="item.props"
                        :prop="item.props"
                        :sortable="item.sortable"
                        show-overflow-tooltip
                        :fixed="item.fixed"
                    ></el-table-column>
                    <el-table-column
                        v-if="menuAuths.deleteBut"
                        width="120"
                        align="center"
                        :label="$t('message.operating')"
                        fixed="right"
                    >
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                :disabled="scope.row.status === 'CONFIRM'"
                                @click="del(scope.row.id)"
                                size="mini"
                            >
                                {{ $t('message.delete') }}
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="edu-pagination">
                    <div class="float-right">
                        <el-pagination
                            :current-page="page.pageNum_"
                            :page-sizes="[20, 50, 100, 500, 1000]"
                            :page-size="page.pageSize_"
                            :total="page.total"
                            layout="total, sizes, prev, pager, next, jumper"
                            style="float: right;margin:0;"
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                        />
                    </div>
                </div>
            </el-card>
        </div>

        <!-- 新增页面 -->
        <div v-if="indexKey == '1'">
            <condition-card @reset="handleResetFilter('queryForm')" @search="searchAddList">
                <el-form label-position="right" label-width="120px">
                    <el-row :gutter="24">
                        <el-col :span="8">
                          <el-form-item :label="$t('label.schoolTerm')">
                            <CalendarSelect v-model="queryAddForm.yearTerm"></CalendarSelect>
                          </el-form-item>
                        </el-col>
                        <el-col :span="8">
                          <el-form-item :label="$t('label.grade')">
                            <el-date-picker
                              v-model="queryAddForm.grade"
                              value-format="yyyy"
                              type="year"
                              :placeholder="$t('message.plzSelect')"
                              style="width: 100%"
                              :clearable="false"
                            />
                          </el-form-item>
                        </el-col>
                        <el-col :span="8">
                        <el-form-item :label="$t('fundingManagement.label.courseOpenAcademy')">
                            <DictSelect
                                v-model="queryAddForm.courseOpenAcademyId"
                                :data="options.courseOpenAcademyId"
                                :clearable="false"
                                :filterable="true"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                    </el-row>
                    <el-row :gutter="24">
                        <el-col :span="8">
                            <el-form-item
                                :label="$t('courseConfirmation.label.stuFaculty')"
                                prop="studentAcademyId"
                            >
                                <DictSelect
                                    v-model="queryAddForm.studentAcademyId"
                                    :data="options.studentAcademyId"
                                    :clearable="false"
                                ></DictSelect>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('label.major')" prop="majorId">
                                <MyMajor
                                    :faculty="queryAddForm.studentAcademyId"
                                    v-model="queryAddForm.majorId"
                                    :grade="queryAddForm.grade"
                                ></MyMajor>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('arrCourse.label.courseCodeOrName')">
                                <el-input
                                    v-model="queryAddForm.courseCodeOrName"
                                    maxlength="30"
                                    :placeholder="$t('courseConfirmation.tips.keyTips')"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </condition-card>
            <el-card body-style="padding: 24px;">
                <!-- <div class="edu-page-box"> -->
                <div class="edu-page-title">{{ $t('arrCourse.title.listTitle') }}</div>
                <div class="edu-opertion-bar">
                    <div style="width:300px;margin-top: 18px;">
                        <el-form :model="queryAddForm" label-width="80px" :rules="rule">
                            <el-form-item :label="$t('label.schoolTerm')" prop="yearTerm">
                                <CalendarSelect v-model="this.currentTermCalendar" :disabled="true"></CalendarSelect>
                            </el-form-item>
                        </el-form>
                    </div>
                </div>
                <!-- </div> -->
                <el-table
                    ref="tables"
                    :data="data"
                    :row-key="getRowKeys"
                    @selection-change="selectionAdd"
                >
                    <el-table-column width="30" type="selection" fixed="left"></el-table-column>
                    <el-table-column
                        width="50"
                        align="center"
                        type="index"
                        :index="indexMethod"
                        :label="$t('message.order')"
                        fixed="left"
                    ></el-table-column>
                    <el-table-column
                        :min-width="item.width"
                        :align="item.center ? 'center' : ''"
                        v-for="(item, idx) in label2"
                        :label="item.label"
                        :key="item.props"
                        :prop="item.props"
                        :sortable="item.sortable"
                    ></el-table-column>
                </el-table>
                <div class="edu-pagination">
                    <div class="float-right">
                        <el-pagination
                            :current-page="AddFormpage.current"
                            :page-sizes="[20, 50, 100, 500, 1000]"
                            :page-size="AddFormpage.pageSize_"
                            :total="AddFormpage.total"
                            layout="total, sizes, prev, pager, next, jumper"
                            style="float: right;margin:0;"
                            @size-change="addSizeChange"
                            @current-change="addCurrentChange"
                        />
                    </div>
                </div>
                <div class="edu-pagination">
                    <div class="float-right">
                        <el-button @click="cancel">{{ $t('message.cancel') }}</el-button>
                        <el-button type="primary" @click="submitForm">
                            {{ $t('message.confirm') }}
                        </el-button>
                    </div>
                </div>
            </el-card>
        </div>

        <el-dialog
            :title="$t('arrCourse.title.dialogTitle')"
            width="350px"
            :visible.sync="initializeDialog"
            :close-on-click-modal="false"
        >
            <el-form ref="form" :model="searchForm" label-width="80px" :rules="rules">
                <el-form label-width="80px">
                    <el-form-item :label="$t('label.schoolTerm')">
                        <CalendarSelect
                            v-model="searchForm.yearTerm"
                            :disabled="true"
                        ></CalendarSelect>
                    </el-form-item>
                </el-form>
                <el-form-item :label="$t('label.grade')" prop="grade">
                    <el-date-picker
                        v-model="searchForm.grade"
                        value-format="yyyy"
                        type="year"
                        :placeholder="$t('common.text.all')"
                        style="width: 100%"
                    />
                </el-form-item>
            </el-form>
            <div class="edu-pagination">
                <div class="float-right">
                    <el-button @click="cancelDialog">{{ $t('message.cancel') }}</el-button>
                    <el-button type="primary" @click="submitDialog">
                        {{ $t('message.confirm') }}
                    </el-button>
                </div>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { findDept } from 'common/src/api/user'
import Calendars from 'common/src/api/calendars'
import commonMixins from '../commonMixins'
import {
    listDdetails,
    unionCourses,
    cancelUnion,
    cancelDdivide,
    divideClass
} from 'common/src/api/practiceManagement/practiceTask'
import {
    deleudgPtCourse,
    initCourse,
    exportUdgptCourseInfo,
    queryCultureCourse,
    addudgPtCourseInfo,
    getCourseInfoList
} from 'common/src/api/practiceManagement/internSetup'
import MyMajor from 'common/src/views/practiceManagement/common/MyMajor'
export default {
    // 组件名称
    name: 'courseList',
    mixins: [commonMixins],
    components: {
        MyMajor
    },
    // 组件参数 接收来自父组件的数据
    props: {},
    // 组件状态值
    data() {
        return {
            initializeDialog: false,
            indexKey: '0',
            breadPath: {
                label: this.$t('courseConfirmation.label.pathLabel'),
                key: '0',
                children: [
                    {
                        key: '1',
                        label: this.$t('courseConfirmation.label.pathAdd')
                    }
                ]
            },

            ids: '',
            selecids: [],
            cultureSchemes: [],
            page: {
                pageNum_: 1,
                pageSize_: 20,
                total: 0
            },
            getRowKeys(row) {
                return row.id
            },
            expands: [],
            data: [],
            label: [
                {
                    label: this.$t('label.schoolTerm'),
                    props: 'yearTermText',
                    width: 190,
                    sortable: true
                },
                { label: this.$t('label.grade'), props: 'grade', width: 90, sortable: true },
                {
                    label: this.$t('fundingManagement.label.courseCode'),
                    props: 'courseCode',
                    width: 100,
                    sortable: true,
                    fixed: 'left'
                },
                {
                    label: this.$t('fundingManagement.label.courseName'),
                    props: 'courseName',
                    width: 130,
                    sortable: true,
                    fixed: 'left'
                },
                {
                    label: this.$t('label.openClassCollege'),
                    props: 'courseOpenAcademy',
                    width: 150,
                    sortable: true
                },
                {
                    label: this.$t('courseConfirmation.label.stuFaculty'),
                    props: 'studentAcademy',
                    width: 150,
                    sortable: true
                },
                { label: this.$t('label.major'), props: 'majorName', width: 150, sortable: true },
                {
                    label: this.$t('label.trainingLevel'),
                    props: 'trainingLevelText',
                    width: 80,
                    sortable: false
                },
                {
                    label: this.$t('courseConfirmation.label.weeks'),
                    props: 'weeks',
                    width: 80,
                    sortable: true
                },
                {
                    label: this.$t('courseConfirmation.label.planCount'),
                    props: 'planCount',
                    width: 100,
                    sortable: true
                }
            ],
            label2: [
                { label: this.$t('label.grade'), props: 'grade', width: 90, sortable: true },
                {
                    label: this.$t('fundingManagement.label.courseCode'),
                    props: 'courseCode',
                    width: 100,
                    sortable: true
                },
                {
                    label: this.$t('fundingManagement.label.courseName'),
                    props: 'courseName',
                    width: 130,
                    sortable: true
                },
                {
                    label: this.$t('label.openClassCollege'),
                    props: 'college',
                    width: 150,
                    sortable: true
                },
                {
                    label: this.$t('courseConfirmation.label.stuFaculty'),
                    props: 'studentAcademy',
                    width: 150,
                    sortable: true
                },
                { label: this.$t('label.major'), props: 'majorName', width: 150, sortable: true },
                {
                    label: this.$t('label.trainingLevel'),
                    props: 'trainLevelText',
                    width: 80,
                    sortable: false
                },
                {
                    label: this.$t('courseConfirmation.label.weeks'),
                    props: 'weeks',
                    width: 80,
                    sortable: true
                },
                {
                    label: this.$t('courseConfirmation.label.planCount'),
                    props: 'planCount',
                    width: 100,
                    sortable: true
                }
            ],
            queryForm: {
                yearTerm: '', // 学年学期
                grade: '', // 年级
                trainingLevel: 'UDG', // 培养层次
                faculty: '', // 学院院系
                profession: '', // 专业
                course: '', // 课程代码或名称
                courseOpenAcademyId:''//开课学院
            },
            searchForm: {
                yearTerm: '', // 学年学期
                grade: '' // 年级
            },
            exportData: {}, //导出类型：0：根据条件导出，1：导出勾选条件
            exportCondition: {},
            // 下拉相关选项数据
            options: {
                trainingLevel: [], // 培养层次
                studentAcademyId: [], // 学院院系
                courseOpenAcademyId:[],
                majorId: [] // 专业
            },
            // 新增初始化查询条件
            queryAddForm: {
                yearTerm: '', // 学年学期
                grade: moment(new Date()).format("YYYY"), // 年级
                trainingLevel: 'UDG', // 培养层次
                studentAcademyId: '', // 学院院系
                majorId: '', // 专业
                courseCodeOrName: '', // 课程代码或名称
                courseOpenAcademyId:''//开课学院
            },
            AddFormpage: {
                pageNum_: 1,
                pageSize_: 20,
                current: 1,
                total: 0
            },
            currentTermCalendar: '',
            addData: [], //选中新增课程
            rules: {
                grade: [
                    {
                        required: true,
                        message: this.$t('arrCourse.tips.mustHave'),
                        trigger: ['change']
                    }
                ]
            },
            rule: {
                yearTerm: [
                    {
                        required: true,
                        message: this.$t('arrCourse.tips.mustHave'),
                        trigger: 'change'
                    }
                ]
            },
            auths: [],
            menuAuths: {
                addBut: false,
                deleteBut: false,
                deleteBatch: false,
                initBut: false,
                exportBut: false
            }
        }
    },
    watch: {
        auths: {
            handler(newVal) {
                if (newVal && Array.isArray(newVal) && newVal.length > 0) {
                    newVal.some(item => {
                        switch (item.authCode) {
                            case 'courseList-add':
                                this.menuAuths.addBut = true
                            case 'courseList-delete':
                                this.menuAuths.deleteBut = true
                            case 'courseList-deleteBatch':
                                this.menuAuths.deleteBatch = true
                            case 'courseList-courseInit':
                                this.menuAuths.initBut = true
                            case 'courseList-export':
                                this.menuAuths.exportBut = true
                            default:
                                break
                        }
                    })
                }
            }
        }
    },
    created() {
        this.auths = JSON.parse(localStorage.getItem('sessiondata')).auths
    },
    /**
     * 在挂载开始之前被调用：相关的 render 函数首次被调用。
     */
    mounted() {
        let param = {
            X_YX: 'courseOpenAcademyId' // 学院
        }
        this.initOptions(param)
        findDept(0).then(res => {
            if (res.code == 200 && res.data) {
                this.options.studentAcademyId = res.data.map(row => {
                    return { label: row.deptName, value: row.deptCode }
                })
            }
        })
    },

    methods: {
        selectionChange(selection) {
            this.cultureSchemes = selection
            this.selecids = selection.map(item => {
                return item.id
            })
        },

        zydescription(row) {
            // 获取展开数据
            let param = {
                id: row.id
            }
            if (!row.hasOwnProperty('children')) {
                listDdetails(param).then(res => {
                    this.$set(row, 'children', res.data)
                    this.expands = [row.id]
                })
            }
        },
        setClassName({ row }) {
            // 是否有展开项
            return row.mergeFlag !== 'Y' ? 'unexpand' : ''
        },
        rowClick(row) {
            // 单项选择
            this.$refs.mainTables.toggleRowSelection(row)
        },

        handleSizeChange(val) {
            // 分页数量事件
            this.AddFormpage.pageNum_ = 1
            this.$set(this.page, 'pageSize_', val)
            this.getLists()
        },
        handleCurrentChange(val) {
            // 分页当前页事件
            this.$set(this.page, 'pageNum_', val)
            this.getLists()
        },
        handSearchChang() {
            // 搜索
            this.getLists(true)
        },

        getloadDone(data, id) {
            this.queryForm.yearTerm = id
            this.currentTermCalendar = id
            this.getLists(true)
        },

        loadDone(data, id) {
            this.getLists()
        },
        // 重置
        reset() {
            for (const key in this.queryForm) {
                if (key != 'calendarId' && key != 'projectId') {
                    this.queryForm[key] = ''
                }
            }
            this.queryForm.yearTerm = this.currentTermCalendar
            this.queryForm.trainingLevel = 'UDG'
            this.getLists(true)
        },

        onSubmit() {
            // 筛选
            this.getLists(true)
        },
        getLists(refresh) {
            // 获取数据
            this.expands = []
            if (refresh) {
                this.page.pageNum_ = 1
            }
            let jsons = {
                condition: this.queryForm,
                pageNum_: this.page.pageNum_,
                pageSize_: this.page.pageSize_
            }
            getCourseInfoList(jsons).then(res => {
                this.data = res.data.list
                this.page.total = res.data.total_
            })
        },
        cancelDialog() {
            this.initializeDialog = false
        },
        submitDialog() {
            this.$refs.form.validate(valid => {
                if (valid) {
                    this.$confirm(
                        this.$t('arrCourse.tips.confirmTips'),
                        this.$t('message.prompt'),
                        {
                            confirmButtonText: this.$t('message.confirm'),
                            cancelButtonText: this.$t('message.cancel'),
                            type: 'warning'
                        }
                    )
                        .then(() => {
                            let jsons = {
                                yearTerm: this.searchForm.yearTerm,
                                grade: this.searchForm.grade
                            }
                            initCourse(jsons).then(res => {
                                this.initializeDialog = false
                                this.$message.success(this.$t('arrCourse.tips.initTips'))
                                this.getLists(true)
                            })
                        })
                        .catch(e => {
                            this.initializeDialog = false
                        })
                }
            })
        },

        // 打开新增页
        addCourse() {
            this.indexKey = '1';
            this.AddFormpage.pageNum_ = 1;
            this.AddFormpage.pageSize_ = 20;
            this.handleResetFilter()
        },
        searchAddList() {
            this.queryAddCultureCourse(true)
        },
        // 重置
        handleResetFilter() {
            for (const key in this.queryAddForm) {
                if (key != 'calendarId' && key != 'projectId') this.queryAddForm[key] = ''
            }
            this.queryAddForm.yearTerm = this.currentTermCalendar
            this.queryAddForm.trainingLevel = 'UDG'
            this.queryAddForm.grade = moment(new Date()).format("YYYY")
            this.queryAddCultureCourse(true)
        },
        exportRecord() {
            this.exportCondition = this.queryForm
            if (this.cultureSchemes.length < 1) {
                this.exportData = {
                    exportType: 0,
                    exportCondition: this.exportCondition
                }
            } else {
                this.exportData = {
                    exportType: 1,
                    rows: this.cultureSchemes,
                    exportCondition: this.exportCondition
                }
            }
            exportUdgptCourseInfo(this.exportData)
            // if (type === '1') {
            //     this.exportData = {
            //         exportType: 0,
            //         exportCondition: this.exportCondition
            //     }
            // } else if (type === '2') {
            //     if (this.cultureSchemes.length < 1) {
            //         this.$message({ type: "warning", message: "提示：请勾选要导出的数据！" });
            //         return;
            //     }
            //     this.exportData = {
            //         exportType: 1,
            //         rows: this.cultureSchemes,
            //         exportCondition: this.exportCondition
            //     }
            // }
            // exportUdgptCourseInfo(this.exportData);
        },
        initialize() {
            this.initializeDialog = true
            this.searchForm.yearTerm = this.currentTermCalendar
        },
        // 批量删除
        deleteItems() {
            if (this.selecids.length === 0) {
                this.$message({
                    type: 'warning',
                    message: this.$t('practiceManagement.tips.plzData')
                })
                return
            }
            let flag = this.cultureSchemes.some(item => {
                return item.status === 'CONFIRM'
            })
            if (flag) {
                this.$message({ type: 'warning', message: this.$t('arrCourse.tips.checkTips') })
                return
            }
            this.$confirm(this.$t('message.areYouSureDelete'), this.$t('message.prompt'), {
                confirmButtonText: this.$t('message.confirm'),
                cancelButtonText: this.$t('message.cancel'),
                type: 'warning'
            })
                .then(() => {
                    deleudgPtCourse({ ids: this.selecids }).then(res => {
                        if (res.code === 200) {
                            this.$message({
                                type: 'success',
                                message: this.$t('message.deleteSuccess')
                            })
                            this.getLists(true)
                        }
                    })
                })
                .catch(e => {})
        },
        // 删除
        del(id) {
            this.$confirm(this.$t('message.areYouSureDelete'), this.$t('message.prompt'), {
                confirmButtonText: this.$t('message.confirm'),
                cancelButtonText: this.$t('message.cancel'),
                type: 'warning'
            })
                .then(() => {
                    deleudgPtCourse({ ids: [id] }).then(res => {
                        if (res.code === 200) {
                            this.$message({
                                type: 'success',
                                message: this.$t('message.deleteSuccess')
                            })
                            this.getLists(true)
                        }
                    })
                })
                .catch(e => {})
        },

        //取消新增课程
        cancel() {
            this.indexKey = '0';
            this.getLists(true);
        },
        // 新增初始化
        queryAddCultureCourse(refresh) {
            if (refresh) {
              this.AddFormpage.pageNum_ = 1
            }
            // 获取数据
            let jsons = {
                condition: this.queryAddForm,
                pageNum_: this.AddFormpage.pageNum_,
                pageSize_: this.AddFormpage.pageSize_
            }
            queryCultureCourse(jsons).then(res => {
                this.data = res.data.records
                this.AddFormpage.total = res.data.total
                this.AddFormpage.current = res.data.current
            })
        },

        addSizeChange(val) {
            // 分页数量事件
            this.AddFormpage.pageSize_ = val;
            this.queryAddCultureCourse(true);
        },
        addCurrentChange(val) {
            // 分页当前页事件
            this.AddFormpage.pageNum_ = val
            this.queryAddCultureCourse()
        },
        // 选中新增数据
        selectionAdd(selection) {
            this.addData = selection
        },
        //  提交新增
        submitForm() {
            if (this.addData.length === 0) {
                this.$message({ type: 'warning', message: this.$t('arrCourse.tips.addTips') })
                return
            }
            this.$confirm(this.$t('message.areYouSureAdd'), this.$t('message.prompt'), {
                confirmButtonText: this.$t('message.confirm'),
                cancelButtonText: this.$t('message.cancel'),
                type: 'warning'
            })
                .then(() => {
                    let jsons = {
                        yearTerm: this.currentTermCalendar,
                        bclCulturePlanReceivers: this.addData
                    }
                    addudgPtCourseInfo(jsons).then(res => {
                        if (res.code === 200) {
                            this.$message({
                                type: 'success',
                                message: this.$t('message.submitSuccess')
                            })
                            this.indexKey = '0'
                            // this.getLists();
                        }
                    })
                })
                .catch(e => {})
        },
        indexMainMethod(index) {
          return (this.page.pageNum_ - 1) * this.page.pageSize_ + index + 1;
        },
        indexMethod(index) {
          return (this.AddFormpage.pageNum_ - 1) * this.AddFormpage.pageSize_ + index + 1;
        },
    }
}
</script>
<style lang="scss" scoped>
.titles {
    font-weight: bold;
    color: #2b3b4e;
}
.expandTable {
    ::v-deep td {
        border: none;
    }
    .el-table::before {
        width: 0;
        height: 0;
    }
}
.opreate {
    display: flex;
    justify-content: space-between;
}
::v-deep.unexpand .el-table__expand-column .cell {
    display: none;
}
.edu-page-box {
    display: flex;
}
.edu-page-title {
    width: 120px;
    font-size: 18px;
    font-weight: 600;
}
</style>
